* this do-file runs the panel regression for Table 2
* the last part runs the panel regression for rubustness check

set more off

cd d:\data

use panel_16c_final, clear

drop country-gyear
drop tcit
drop t1980 s69 c6 US*


* min was .0188679, 1781 obs with y=0 (N=15,746)
replace y = 0.018 if y == 0
replace y= log(y)

* min was .0144987, 1972 obs with y_n=0 (N=15,746)
replace y_n = 0.014 if y_n == 0
replace y_n = log(y_n)

* min was .0588235, 472 obs with y_5=0 (N=14,009)
replace y_5 = 0.058 if y_5 == 0
replace y_5 = log(y_5)

* min was .0606179, 523 obs with y_n_5=0 (N=14,009)
replace y_n_5 = 0.060 if y_n_5 == 0
replace y_n_5 = log(y_n_5)

for var JP DE EU FR GB TW KR CA CH AU IL CN IN RU RW : replace X = X - (X1989_1999 + X1999)


reg y s* t* JP DE EU FR GB TW KR CA CH AU IL CN IN RU RW JP1989_1999 DE1989_1999 EU1989_1999 FR1989_1999 GB1989_1999 TW1989_1999 KR1989_1999 CA1989_1999 CH1989_1999 AU1989_1999 IL1989_1999 CN1989_1999 IN1989_1999 RU1989_1999 RW1989_1999 JP1999 DE1999 EU1999 FR1999 GB1999 TW1999 KR1999 CA1999 CH1999 AU1999 IL1999 CN1999 IN1999 RU1999 RW1999 [aweight=b_cst], vce(cl CS)
estimates store m1

reg y_n s* t* JP DE EU FR GB TW KR CA CH AU IL CN IN RU RW JP1989_1999 DE1989_1999 EU1989_1999 FR1989_1999 GB1989_1999 TW1989_1999 KR1989_1999 CA1989_1999 CH1989_1999 AU1989_1999 IL1989_1999 CN1989_1999 IN1989_1999 RU1989_1999 RW1989_1999 JP1999 DE1999 EU1999 FR1999 GB1999 TW1999 KR1999 CA1999 CH1999 AU1999 IL1999 CN1999 IN1999 RU1999 RW1999 [aweight=b_cst], vce(cl CS)
estimates store m2

reg y_5 s* t* JP DE EU FR GB TW KR CA CH AU IL CN IN RU RW JP1989_1999 DE1989_1999 EU1989_1999 FR1989_1999 GB1989_1999 TW1989_1999 KR1989_1999 CA1989_1999 CH1989_1999 AU1989_1999 IL1989_1999 CN1989_1999 IN1989_1999 RU1989_1999 RW1989_1999 JP1999 DE1999 EU1999 FR1999 GB1999 TW1999 KR1999 CA1999 CH1999 AU1999 IL1999 CN1999 IN1999 RU1999 RW1999 [aweight=b_cst], vce(cl CS)
estimates store m3

reg y_n_5 s* t* JP DE EU FR GB TW KR CA CH AU IL CN IN RU RW JP1989_1999 DE1989_1999 EU1989_1999 FR1989_1999 GB1989_1999 TW1989_1999 KR1989_1999 CA1989_1999 CH1989_1999 AU1989_1999 IL1989_1999 CN1989_1999 IN1989_1999 RU1989_1999 RW1989_1999 JP1999 DE1999 EU1999 FR1999 GB1999 TW1999 KR1999 CA1999 CH1999 AU1999 IL1999 CN1999 IN1999 RU1999 RW1999 [aweight=b_cst], vce(cl CS)
estimates store m4

reg y c* t* JP DE EU FR GB TW KR CA CH AU IL CN IN RU RW JP1989_1999 DE1989_1999 EU1989_1999 FR1989_1999 GB1989_1999 TW1989_1999 KR1989_1999 CA1989_1999 CH1989_1999 AU1989_1999 IL1989_1999 CN1989_1999 IN1989_1999 RU1989_1999 RW1989_1999 JP1999 DE1999 EU1999 FR1999 GB1999 TW1999 KR1999 CA1999 CH1999 AU1999 IL1999 CN1999 IN1999 RU1999 RW1999 [aweight=b_cst], vce(cl CS)
estimates store m5

reg y_n c* t* JP DE EU FR GB TW KR CA CH AU IL CN IN RU RW JP1989_1999 DE1989_1999 EU1989_1999 FR1989_1999 GB1989_1999 TW1989_1999 KR1989_1999 CA1989_1999 CH1989_1999 AU1989_1999 IL1989_1999 CN1989_1999 IN1989_1999 RU1989_1999 RW1989_1999 JP1999 DE1999 EU1999 FR1999 GB1999 TW1999 KR1999 CA1999 CH1999 AU1999 IL1999 CN1999 IN1999 RU1999 RW1999 [aweight=b_cst], vce(cl CS)
estimates store m6


estout m1 m2 m3 m4 m5 m6 using "E:\temp\2014.7.30\KLL\datawork\80_11\panel_final.tex", replace cells(b(star fmt(%9.3f) label (Est.)) se(par fmt(%9.3f) label(Std. error))) keep (JP DE EU FR GB TW KR CA CH AU IL CN IN RU RW JP1989_1999 DE1989_1999 EU1989_1999 FR1989_1999 GB1989_1999 TW1989_1999 KR1989_1999 CA1989_1999 CH1989_1999 AU1989_1999 IL1989_1999 CN1989_1999 IN1989_1999 RU1989_1999 RW1989_1999 JP1999 DE1999 EU1999 FR1999 GB1999 TW1999 KR1999 CA1999 CH1999 AU1999 IL1999 CN1999 IN1999 RU1999 RW1999) label msign(--) nolz varwidth(16) modelwidth(13) style(tex) title(Regression results\label{auto}) mlabels(, span prefix(\multicolumn{@span}{c}{) suffix(})) prehead("\begin{table}\caption{@title}" "\begin{center}" "\begin{tabular}{l*{@M}{rr}}" "\hline") posthead(\hline) prefoot("\hline" "\small\textit{* p<0.05, ** p<0.01, *** p<0.001}") postfoot("\end{tabular}" "\end{center}" "\end{table}")
